package cn.mesmile.code.wrapper;

import cn.mesmile.code.entity.Student;
import cn.mesmile.code.support.BaseEntityWrapper;
import cn.mesmile.code.vo.StudentVO;
import org.apache.ibatis.reflection.wrapper.BaseWrapper;
import org.springframework.beans.BeanUtils;

/**
 * @author zb
 * @date 2021/5/14 11:10
 * @Description
 */
public class StudentWrapper extends BaseEntityWrapper<Student, StudentVO> {

    public static StudentWrapper builder(){
        return new StudentWrapper();
    }

    @Override
    public StudentVO entityVO(Student entity) {
        StudentVO studentVO = new StudentVO();
        BeanUtils.copyProperties(entity, studentVO);
        if (studentVO.getSex() == 1){
            studentVO.setSexName("男");
        }else if (studentVO.getSex() == 0) {
            studentVO.setSexName("女");
        }else {
            studentVO.setSexName("未知");
        }
        return studentVO;
    }

}
